Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add ucan receipts capability #1113

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

vasco-santos
Copy link
Contributor

@vasco-santos vasco-santos commented Nov 10, 2023

This PR adds support for getting receipts from executed task (and optionally follow task effects and also get receipts already available).

Capability

Called it ucan/receipt and put it together with ucan/* capabilities. However, I am not entirely sure this would be the expected scope, or maybe the name needs a better feeling of being a getter.

Return type

It is not trivial to define the return type here, so would like feedback. For now, opted for simply mapping what ucanto does, even though I was first considering something like:

interface ReceiptRecord {
  receipt: Receipt
  joinReceipt?: ReceiptRecord
  forkReceipts?:  ReceiptRecord[]
}

which ended up feeling weird to me if chain is not complete.

Encoding

At first, I tried to rely on ReceiptRecord above as the return type of the invocation, which of course means that on the client side Receipt instance is lost. We could capture information enough to re-create it on the client, but I ended up just mimic what ucanto does behind the scenes and encode this as a Message (which given it goes through ucanto, will be a message inside a message 😅 ). However, it felt the cleaner and nicer approach to give back to user Receipts.

@vasco-santos vasco-santos force-pushed the feat/add-ucan-receipts-capability branch 4 times, most recently from 9542f2a to ffd6b4c Compare November 10, 2023 15:33
@vasco-santos vasco-santos force-pushed the feat/add-ucan-receipts-capability branch from ffd6b4c to 8f2808e Compare November 10, 2023 15:45
@vasco-santos vasco-santos marked this pull request as ready for review November 10, 2023 15:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant